package com.test.lua;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Author:yaoxiaojian
 * @Description:
 * @Date:create in 2020/5/26 16:43
 * @Modified By:
 */
public class RedisManager {


	private static JedisPool jedisPool;

	static{
		JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
		jedisPoolConfig.setMaxTotal(20);
		jedisPoolConfig.setMaxIdle(10);
		jedisPool = new JedisPool(jedisPoolConfig,"127.0.0.1",6379);
	}

	public static Jedis getJedis(){
		if(null != jedisPool){
			return jedisPool.getResource();
		}
		throw new RuntimeException("JedisPool was not init!");
	}
	
}
